﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using HCQ2_Common.Constant;

namespace HCQ2_Common
{
    /// <summary>
    /// 获取当前操作用户信息
    /// </summary>
    public class CurrentInfo
    {
        /// <summary>
        /// 获取当前操作用户ID
        /// </summary>
        /// <returns></returns>
        public static int GetUserId()
        {
            object userId = HttpContext.Current.Session[AuthorityConstant.USER_ID];
            if (userId == null)
            {
                return 0;
            }
            return Convert.ToInt32(userId);
        }

        /// <summary>
        /// 获取当前操作用户的登陆名称
        /// </summary>
        /// <returns></returns>
        public static string GetLoginName()
        {
            object obj = HttpContext.Current.Session[AuthorityConstant.LOGIN_NAME];

            return Convert.ToString(obj);
        }
        /// <summary>
        /// 获取当前用户的用户名称
        /// </summary>
        /// <returns></returns>
        public static string GetUserName()
        {
            object obj = HttpContext.Current.Session[AuthorityConstant.USER_NAME];

            return Convert.ToString(obj);
        }

        /// <summary>
        /// 获取当前用户请求接口提供的userid值
        /// </summary>
        /// <returns></returns>
        public static string GetUserGuid()
        {
            object obj = HttpContext.Current.Session[AuthorityConstant.USER_GUID];

            return Convert.ToString(obj);
        }
    }
}
